import request from "@/api";
import { BaseRet, PageQuery, PageRet } from "../response";

export default class DesignListApi {
  /**
   * 查询
   * @returns
   */
  static async query(data: DesignListQuery): Promise<PageRet<DesignListModel>> {
    return await request({
      url: "/designList/query",
      method: "post",
      data: data,
    });
  }

  /**
   * 新增
   * @returns
   */
  static async create(data: DesignListEdit): Promise<BaseRet> {
    return await request({
      url: `/designList/create`,
      method: "post",
      data: data,
    });
  }

  /**
   * 修改
   * @returns
   */
  static async update(data: DesignListEdit): Promise<BaseRet> {
    return await request({
      url: `/designList/update`,
      method: "put",
      data: data,
    });
  }

  /**
   * 删除
   * @returns
   */
  static async delete(id: string): Promise<BaseRet> {
    return await request({
      url: `/designList/delete/${id}`,
      method: "delete",
    });
  }

  /**
   * 详情
   * @returns
   */
  static async details(id: string): Promise<DesignListEdit> {
    return await request({
      url: `/designList/details/${id}`,
      method: "get",
    });
  }
}

export interface DesignListModel {
  id?: string;
  name?: string;
  formId?: string;
  formName?: string;
}

export interface DesignListQuery extends PageQuery {
  searchString?: string;
}

export interface DesignListEdit {
  id?: string;
  name?: string;
  formId?: string;
  formName?: string;
  tableConfig?: string;
  listConfig?: DesignListConfig;
  menuConfig?: DesignListMenuInfo;
}

export interface DesignListMenuInfo {
  parentId?: string;
  order?: string;
}

export interface DesignListConfig {
  defaultOrder?: "ascending" | "descending";
  defaultOrderBy?: string;
}
